<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0 ,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>结算页面</title>

    <link th:href="@{/assets/css/amazeui.css}" rel="stylesheet" type="text/css"/>

    <link th:href="@{/basic/css/demo.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/css/cartstyle.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/css/jsstyle.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/layuiadmin/layui/layui.css}" rel="stylesheet" type="text/css"/>
    <script th:src="@{/layuiadmin/layui/layui.all.js}">  </script>

    <script type="text/javascript" th:src="@{/js/address.js}"></script>
    <script th:src="@{/assets/js/jquery.min.js}"></script>


</head>

<body>

<!--顶部导航条 -->
<div th:include="public/pagehead::common"></div>

<!--悬浮搜索框-->

<div class="nav white">
    <div class="logo"><img th:src="@{/images/logo.png}"/></div>
    <div class="logoBig">
        <li><img th:src="@{/images/logobig.png}"/></li>
    </div>

    <div class="search-bar pr">
        <a name="index_none_header_sysc" href="#"></a>
        <form>
            <input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索" autocomplete="off">
            <input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
        </form>
    </div>
</div>

<div class="clear"></div>
<div class="concent">
    <!--地址 -->
    <div class="paycont">
        <div class="address">
            <h3>确认收货地址 </h3>
            <div class="control">
                <div class="tc-btn createAddr theme-login am-btn am-btn-danger">使用新地址</div>
            </div>
            <div class="clear"></div>
            <ul>
                <div class="per-border"></div>

                <li class="user-addresslist" th:each="address: ${session.addressList}"  >
                    <div class="address-left" th:name="${session.orderNo}" th:id="${address.getAddId()}">
                        <div class="user DefaultAddr">

										<span class="buy-address-detail">
                   <span class="buy-user" th:text="${address.getConsignee()}">艾迪 </span>
										<span class="buy-phone" th:text="${address.getPhone()}">15871145629</span>
										</span>
                        </div>
                        <div class="default-address DefaultAddr">
                            <span class="buy-line-title buy-line-title-type">收货地址：</span>
                            <span class="buy--address-detail">
								   <span class="province" th:text="${address.getProvince()}">湖北</span>省
										<span class="city" th:text="${address.getCity()}">武汉</span>市
										<span class="dist" th:text="${address.getDistrict()}">武昌</span>
										<span class="street" th:text="${address.getAddress()}">东湖路75号众环大厦2栋9层902</span>
                            </span>
                            </span>
                        </div>

                    </div>
                    <div class="address-right">
                        <span class="am-icon-angle-right am-icon-lg"></span>
                    </div>
                    <div class="clear"></div>

                    <div class="new-addr-btn">
                        <a href="javascript:void(0);" class="del" th:name="${address.getAddId()}">删除</a>
                    </div>

                </li>

            </ul>

            <div class="clear"></div>
        </div>

        <!--支付方式-->
        <div class="logistics">
            <h3>选择支付方式</h3>
            <ul class="pay-list">
                <li class="pay taobao"><img th:src="@{/images/zhifubao.jpg}"/>支付宝<span></span></li>
            </ul>
        </div>
        <div class="clear"></div>

        <!--订单 -->
        <div class="concent">
            <div id="payTable">
                <h3>确认订单信息</h3>
                <div class="cart-table-th">
                    <div class="wp">

                        <div class="th th-item">
                            <div class="td-inner">商品信息</div>
                        </div>
                        <div class="th th-price">
                            <div class="td-inner">单价</div>
                        </div>
                        <div class="th th-amount">
                            <div class="td-inner">数量</div>
                        </div>
                        <div class="th th-sum">
                            <div class="td-inner">金额</div>
                        </div>
                        <div class="th th-oplist">
                            <div class="td-inner">配送方式</div>
                        </div>

                    </div>
                </div>
                <div class="clear"></div>


                <tr id="J_BundleList_s_1911116345_1" class="item-list">
                    <div id="J_Bundle_s_1911116345_1_0" class="bundle  bundle-last">
                        <div class="bundle-main" th:each="product: ${session.productList}">
                            <ul class="item-content clearfix">
                                <div class="pay-phone">
                                    <li class="td td-item shopId" th:id="${product.getId()}">
                                        <div class="item-pic">
                                            <a href="#" class="J_MakePoint">
                                                <img th:src="${product.getImage()}"
                                                     class="itempic J_ItemImg" style="width: 95px;height: 80px"></a>
                                        </div>
                                    </li>
                                    <li class="td td-info">
                                        <div class="item-props">
                                            <span th:text="${product.getProdDesc()}">颜色：10#蜜橘色+17#樱花粉</span>
                                        </div>
                                    </li>
                                    <li class="td td-price">
                                        <div class="item-price price-promo-promo">
                                            <div class="price-content">
                                                <em class="J_Price price-now"
                                                    th:text="${product.getUnitPrice()}">39.00</em>
                                            </div>
                                        </div>
                                    </li>
                                </div>

                                <li class="td td-amount">
                                    <div class="amount-wrapper ">
                                        <div class="item-amount ">
                                            <span class="phone-title">购买数量</span>
                                            <div class="sl">
                                                <span class="text_box" name="" type="text"
                                                      th:text="${product.getStorage()}"
                                                      style="width:30px;"/>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                                <li class="td td-sum">
                                    <div class="td-inner">
                                        <em tabindex="0" class="J_ItemSum number"
                                            th:text="${product.getExtend1()}">117.00</em>
                                    </div>
                                </li>
                                <li class="td td-oplist">
                                    <div class="td-inner">
                                        <span class="phone-title">配送方式</span>
                                        <div class="pay-logis">
                                            包邮
                                        </div>
                                    </div>
                                </li>

                            </ul>
                            <div class="clear"></div>

                        </div>
                    </div>
                </tr>

            </div>
            <div class="clear"></div>
            <div class="pay-total">
                <!--留言-->
                <!-- <div class="order-extra">
                     <div class="order-user-info">
                         <div id="holyshit257" class="memo">
                             <label>买家留言：</label>
                             <input type="text" title="选填,对本次交易的说明（建议填写已经和卖家达成一致的说明）" placeholder="选填,建议填写和卖家达成一致的说明"
                                    class="memo-input J_MakePoint c2c-text-default memo-close">
                             <div class="msg hidden J-msg">
                                 <p class="error">最多输入500个字符</p>
                             </div>
                         </div>
                     </div>

                 </div>-->

                <div class="clear"></div>
            </div>
            <!--含运费小计 -->
            <div class="buy-point-discharge ">
                <p class="price g_price ">
                    合计（含运费） <span>¥</span><em class="pay-sum" th:text="${session.total}">244.00</em>
                </p>
            </div>

            <!--信息 -->
            <div class="order-go clearfix">
                <div class="pay-confirm clearfix">
                    <!-- <div class="box">
                         <div tabindex="0" id="holyshit267" class="realPay"><em class="t">实付款：</em>
                             <span class="price g_price ">
                                     <span>¥</span>
                                 <em class="style-large-bold-red " id="J_ActualFee" >244.00</em>
                                             </span>
                         </div>

                         <div id="holyshit268" class="pay-address">

                             <p class="buy-footer-address">
                                 <span class="buy-line-title buy-line-title-type">寄送至：</span>
                                 <span class="buy&#45;&#45;address-detail">
                                    <span class="province">湖北</span>省
                                                 <span class="city">武汉</span>市
                                                 <span class="dist">洪山</span>区
                                                 <span class="street">雄楚大道666号(中南财经政法大学)</span>
                                                 </span>
                                 </span>
                             </p>
                             <p class="buy-footer-address">
                                 <span class="buy-line-title">收货人：</span>
                                 <span class="buy-address-detail">
                                          <span class="buy-user">艾迪 </span>
                                                 <span class="buy-phone">15871145629</span>
                                                 </span>
                             </p>
                         </div>
                     </div>-->

                    <div id="holyshit269" class="submitOrder">
                        <div class="go-btn-wrap">
                            <a id="J_Go" class="btn-go" tabindex="0" title="点击此按钮，提交订单">提交订单</a>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
        </div>

        <div class="clear"></div>
    </div>
</div>

<!-- introduce-->
<div th:include="public/pagehead::footer"></div>

<!--弹框-->
<div class="theme-popover-mask"></div>
<div class="theme-popover">

    <!--标题 -->
    <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> /
            <small>Add address</small>
        </div>
    </div>
    <hr/>
    <div class="am-u-md-12">
        <form class="am-form am-form-horizontal " >

            <div class="am-form-group">
                <label for="user-name" class="am-form-label">收货人</label>
                <div class="am-form-content">
                    <input type="text" name="name" id="user-name" placeholder="收货人">
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-phone" class="am-form-label">手机号码</label>
                <div class="am-form-content">
                    <input id="user-phone" name="phonNumber" placeholder="手机号必填" type="email">
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-phone" class="am-form-label">所在地</label>
                <div class="am-form-content address">
                    <select data-am-selected name="province">
                        <option value="a">河南省</option>
                        <option value="b">湖北省</option>
                    </select>
                    <select data-am-selected name="city">
                        <option value="a">南阳市</option>
                        <option value="b">武汉市</option>
                    </select>
                    <select data-am-selected name="country">
                        <option value="a">宛城区</option>
                        <option value="b">洪山区</option>
                    </select>
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-intro" class="am-form-label">详细地址</label>
                <div class="am-form-content">
                    <textarea class="" rows="3" id="user-intro" placeholder="输入详细地址" name="xxaddress"></textarea>
                    <small>100字以内写出你的详细地址...</small>
                </div>
            </div>

            <div class="am-form-group theme-poptit">
                <div class="am-u-sm-9 am-u-sm-push-3">
                    <div class="am-btn am-btn-danger submit">保存</div>
                    <div class="am-btn am-btn-danger close">取消</div>
                </div>
            </div>
        </form>
    </div>

</div>

<div class="clear"></div>
<script >

    ;!function(){
        //无需再执行layui.use()方法加载模块，直接使用即可
        var form = layui.form
            , layer = layui.layer;
        var $ = layui.$
            , admin = layui.admin
            , element = layui.element
            , layer = layui.layer
            , laydate = layui.laydate
            , form = layui.form;
        form.render();
        laydate.render();

            var shops = [];
            for (var i= 0;i<$('.shopId').length;i++){
                var shopId = $('.shopId')[i].id
                var num = $($('.td-amount')[i]).find('.text_box').text()
                shops.push({shopId:shopId,num:num})
            }

            var addId;
            var No
            $('.user-addresslist').on('click',function () {
                addId = $(this).find('.address-left')[0].id
                No=$($(this).find('.address-left')[0]).attr('name')
            })

            $('.go-btn-wrap').on('click',function () {
                var order = {};
                console.log(No)
                console.log(addId)
                if (addId === undefined){
                    layer.msg('请选择收货地址')
                }else{
                    document.location.href = 'alipay?orderNo='+No+'&addId='+addId
                }
            })

        //提交表单
        $('.submit').on('click',function () {
            var name = $("input[name='name']").val()
            if(name === ''){
                console.log('error')
            }
            var phonNumber = $("input[name='phonNumber']").val()
            var province = $("select[name='province'] option:selected").text()
            var city = $("select[name='city'] option:selected" ).text()
            var country = $("select[name='country'] option:selected").text()
            var xxaddress = $("textarea[name='xxaddress']").val()
            console.log('name='+name+'phonNumber='+phonNumber+'province='+province+'city='+city+'country='+country+'xxaddress='+xxaddress)
            var addressVo={};
            addressVo.shouhuoer = name;
            addressVo.phone = phonNumber;
            addressVo.shengfen = province;
            addressVo.city = city;
            addressVo.qu = country;
            addressVo.address1 = xxaddress;
            if (name === ''|| phonNumber===''|| province===''||city===''||country===''||xxaddress===''){
                    layer.msg('请补全信息')
            }else {
                $.ajax({
                    url:'address1',
                    type:'post',
                    data:JSON.stringify(addressVo),
                    async:false,
                    contentType: "application/json",
                    success:function (res) {
                        if(res.code==1){
                            layer.msg(res.msg,{
                                icon:6
                            },function () {
                                window.location.reload()
                            })
                        }else {
                            layer.msg(res.msg)
                        }
                        console.log('success')
                    }
                })
            }

        })

        //删除地址信息
        $('.del').click(function () {
            var id = $(this).attr('name');
            console.log(id)
            layer.confirm('确定删除',function () {
                $.ajax({
                    type:'post',
                    url:'delAddress',
                    data:{id:id},
                    dataType:'json',
                    // contentType:'application/json',
                    success:function (res) {
                        if (res.code==1){
                            layer.msg(res.msg,{
                                icon:6
                            },function () {
                                window.location.reload()
                            })
                        }else{
                            layer.msg(res.msg,{
                                icon:5
                            })
                        }
                    }
                })
            })
        })

    }();

</script>
</body>

</html>